#include "exti.h"
#include "led.h"
void Exti_Init(void)
{
    rcu_periph_clock_enable(RCU_AF);

    nvic_priority_group_set(NVIC_PRIGROUP_PRE2_SUB2);

    nvic_irq_enable(EXTI1_IRQn, 2, 2);
    nvic_irq_enable(EXTI2_IRQn, 2, 2);
    nvic_irq_enable(EXTI3_IRQn, 2, 2);

    exti_init(EXTI_1, EXTI_INTERRUPT, EXTI_TRIG_FALLING);
    exti_init(EXTI_2, EXTI_INTERRUPT, EXTI_TRIG_RISING);
    exti_init(EXTI_3, EXTI_INTERRUPT, EXTI_TRIG_BOTH);

    exti_interrupt_flag_clear(EXTI_1);
    exti_interrupt_flag_clear(EXTI_2);
    exti_interrupt_flag_clear(EXTI_3);
}
void EXTI1_IRQHandler(void)
{
    LED1_Toggle();
    exti_interrupt_flag_clear(EXTI_1);
}
void EXTI2_IRQHandler(void)
{
    LED2_Toggle();
    exti_interrupt_flag_clear(EXTI_2);
}
void EXTI3_IRQHandler(void)
{
    LED2_Toggle();
    exti_interrupt_flag_clear(EXTI_3);
}
